package org.ioc.com.springioc5;

import org.ioc.com.springioc5.controller.UserController;
import org.ioc.com.springioc5.model.UserInfo;
import org.ioc.com.springioc5.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIoc5Application {

    public static void main(String[] args) {
        ApplicationContext context=SpringApplication.run(SpringIoc5Application.class, args);

        System.out.println("------------------------------------------------------------");
        UserService userService = (UserService) context.getBean("userService");
        userService.say();
        UserService bean2 = context.getBean(UserService.class);
        bean2.say();
        UserService userService1 = context.getBean("userService", UserService.class);
        userService1.say();
        System.out.println("------------------------------------------------------------");

        //UserInfo bean3 = context.getBean(UserInfo.class);
        //System.out.println(bean3);
        System.out.println("------------------------------------------------------------");
        UserController userController = (UserController) context.getBean("userController");
        userController.say();
        UserController bean = context.getBean(UserController.class);
        bean.say();
        UserController bean1 = context.getBean("userController", UserController.class);
        bean1.say();
        System.out.println("------------------------------------------------------------");
        UserInfo userInfo1 = (UserInfo) context.getBean("userInfo1");
        System.out.println(userInfo1);

    }

}
